<?php
require_once '../application/library/helper/messageHelper.php';
require_once '../application/library/helper/configHelper.php';
require_once '../application/library/helper/sessionHelper.php';
require_once '../application/library/controller/gcLBasicAction.php';
require_once '../application/library/exception/gcExceptionDealer.php';
require_once '../application/modules/goods/constant/goods_constant_constant.php';
require_once '../application/modules/goods/constant/goods_constant_templatName.php';
require_once '../application/modules/common/services/common_services_categoryTagService.php';
require_once '../application/modules/goods/services/goods_services_goodsDetailsService.php';
/**
 * 商品详细画面Controller
 * @version   1.0
 * @author    Suda
 */
class goods_goodsDetailsController extends gcLBasicAction {

    private $objGoodsDetailsService;

    private $arrMessages = array();
    /**
    * 新规画面初期化
    * @throws gcException
    */
    public function indexAction() {
        try {
            $this->initMenu("1");
            $this->boolUserTypeCheck("1");
            $this->pvSetGoodsPageInfo();
            $strGoodsNo = $this->getParam("goodsNo");
            $this->objGoodsDetailsService = new goods_services_goodsDetailsService();
            $arrGoodsInfo = $this->objGoodsDetailsService->pbGetGoodsInfo($strGoodsNo);
            $this->objCategoryTagService       = new common_services_categoryTagService();
            $this->gcView->arrGoodsFirstCATG   = $this->objCategoryTagService->pbGetGoodsFirstCategory();
//            $arrCondition["FirstCatg"] = "1";
            if ($arrGoodsInfo["FIRST_CATG_NO"] != "" && $arrGoodsInfo["FIRST_CATG_NO"] != null) {
                $this->gcView->arrGoodsSecondCATG = $this->objCategoryTagService->pbGetGoodsSecondCategory($arrGoodsInfo["FIRST_CATG_NO"]);
            } else {}
            $this->gcView->selGoodsFirstCATG   = $arrGoodsInfo["FIRST_CATG_NO"];
            $this->gcView->selGoodsSecondCATG  = $arrGoodsInfo["SECOND_CATG_NO"];
            $this->gcView->arrGoodsInfo = $arrGoodsInfo;
            $this->gcView->GoodsNo = $strGoodsNo;
            $arrSupplierInfo = $this->objGoodsDetailsService->pbGetSupplierInfo($strGoodsNo);
            $this->gcView->SupplierInfo = $arrSupplierInfo;
            $this->gcView->render(goods_constant_TemplatName::GOODS_DETAILS);
        } catch (Exception $e) {
            gcExceptionDealer::setException($e);
        }
    }

    /**
    * 画面信息设定
    * pvSetGoodsPageInfo
    */
    private function pvSetGoodsPageInfo() {
        $this->gcView->title    = $this->getLabel("goods_EC0003_TopPageTitle");
        $this->gcView->goodsTitle = $this->getLabel("goods_EC0003_GoodsTitle");
        $this->gcView->goodsInfo1 = $this->getLabel("goods_EC0003_GoodsInfo1");
        $this->gcView->goodsTitle2 = $this->getLabel("goods_EC0003_GoodsTitle2");
        $this->gcView->goodsCodeLabel = $this->getLabel("goods_EC0003_GoodsCode");
        $this->gcView->goodsNameLabel = $this->getLabel("goods_EC0003_GoodsName");
        $this->gcView->categoryLabel = $this->getLabel("goods_EC0003_Category");
        $this->gcView->variationLabel = $this->getLabel("goods_EC0003_Variation");
        $this->gcView->sellPriceLabel = $this->getLabel("goods_EC0003_SellPrice");
        $this->gcView->basicPriceLabel = $this->getLabel("goods_EC0003_BasicPrice");
        $this->gcView->amountUnitLabel = $this->getLabel("goods_EC0003_AmountUnit");
        $this->gcView->sellPriceLabel2 = $this->getLabel("goods_EC0003_SellPrice2");
        $this->gcView->stockLabel = $this->getLabel("goods_EC0003_Stock");
        $this->gcView->goods_EC0003_SupplierLabel = $this->getLabel("goods_EC0003_SupplierLabel");
        $this->gcView->goods_EC0003_Edit = $this->getLabel("goods_EC0003_Edit");
        $this->gcView->goods_EC0003_Back = $this->getLabel("goods_EC0003_Back");
    }
}